package cn.cslg.tieba.domain.dao;

import cn.cslg.tieba.domain.entity.Tie;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author Wu Zhenwei
 * 2017/11/21
 */
@Mapper
public interface TieDao {

    @Select("select * from tie where tieId = #{tieId}")
    Tie findById(Integer tieId);

    @Select("select * from tie where baId = #{baId}")
    List<Tie> findByBa(Integer baId);

    @Insert("insert into tie(title,baId,userId) values(#{title},#{baId},#{userId})")
    @Options(useGeneratedKeys = true, keyColumn = "tieId", keyProperty = "tieId")
    void insert(Tie tie);

    @Update("update tie set lastFloorNo = lastFloorNo + 1 where tieId = #{tieId}")
    void increaseLastFloor(Integer tieId);
}
